package 逆波兰表达式求值;

public class Test {
    public static void main(String[] args) {

        Solution solution = new Solution();
        String[] s = {"10","6","9","3","+","-11","*","/","*","17","+","5","+"};
        System.out.println(solution.evalRPN(s));

        System.out.println(stringToInteger("-1234"));

    }

    private static Integer stringToInteger(String num) {
        int result = 0;
        int len = num.length();
        int i = 0;
        // 标记num是否为一个负数
        boolean flag = false;
        // 如果num是一个负数，则从1开始遍历num
        if (num.charAt(0) == '-') {
            i = 1;
            flag = true;
        }
        while (i < len) {
            char c = num.charAt(i);
            result = 10 * result + (c - '0');
            i++;
        }
        return flag ? -result : result;
    }
}
